import ccclass = cc._decorator.ccclass;
import property = cc._decorator.property;
import {gameData} from "./GameData";
import ListCtrl from "./ListCtrl";

@ccclass()
export default class EndScene extends cc.Component {
  @property(cc.Sprite)
  private display: cc.Sprite = null;
  @property(cc.Label)
  private score: cc.Label = null;
  @property(cc.ScrollView)
  private scrollView: cc.ScrollView = null;
  @property(cc.Prefab)
  private smallBellPrefab: cc.Prefab = null;
  @property
  private time: number = 0;
  @property(cc.Sprite)
  private Sprite02: cc.Sprite = null;
  @property(cc.Label)
  private title: cc.Label = null;

  private listCtrl: ListCtrl;

  onLoad() {
    this.listCtrl = this.getComponent(ListCtrl);
    let str = this.score.getComponent(cc.Label);
    str.string = gameData.myScore + '';
    if (gameData.maxScore === gameData.myScore) {
      this.Sprite02.node.active = true;
      this.title.getComponent(cc.Label).string = "最高得分";
    } else {
      this.Sprite02.node.active = false;
      this.title.getComponent(cc.Label).string = "本次得分";
    }
  }

  start() {
    this.listCtrl.init(5);
  }
}
